package app.modules.cloudpivot.function;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.authine.cloudpivot.engine.SelectionValue;
import com.authine.cloudpivot.engine.workflow.spi.function.ConditionFunction;

/**
 * 自定义路由条件
 *
 * @author LiuGangQiang Create in 2025/11/12
 */
public class CustomConditionFunction extends ConditionFunction {
    private static final long serialVersionUID = -2701990813369380687L;
    private static final Logger log = LoggerFactory.getLogger(CustomConditionFunction.class);

    /**
     * 路由判断的方法
     *
     * @author LiuGangQiang Create in 2023/03/22
     * @param users 人员单选或多选
     * @return {@link Boolean}
     */
    public boolean resolveFunction(List<SelectionValue> users) {
        log.info("===>>执行自定义路由函数 参数类型:{} 参数:{} ", users.getClass().getCanonicalName(), users);
        if (users.size() > 0) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public String getName() {
        return "CustomConditionDemo";
    }

    @Override
    public String getFullName() {
        return "CustomConditionDemo()";
    }

    @Override
    public String getDisplayName() {
        return "二开的路由函数";
    }

    @Override
    public String getDescription() {
        return "CustomConditionDemo(x),自定义路由函数,目前未实现什么逻辑,只是简单判断人员单选或多选是否为空，不为空则为真反正则为假。大家可以自行实现对应的路由逻辑，请注意的是此函数只支持人员单选多选控件作为参数，其他参数会异常";
    }
}
